"""
题目31：请输入星期几的第一个字母来判断一下是星期几，如果第一个字母一样，则继续判断第二个字母。
"""


def timu31():
    """
    Monday（星期一）、Tuesday（星期二）、Wednesday（星期三）、Thursday（星期四）、Friday（星期五）、Saturday（星期六）、Sunday（星期日）
    """
    first = input("输入：").upper()
    print(first)
    if first == "M":
        print("是周一")

    elif first == "T":
        second = str(input("输入："))
        if second == "u":
            print("是周二")
        elif second == "h":
            print("是周四")
        else:
            print("啥也不是")
    elif first == "W":
        print("是周三")
    elif first == "F":
        print("是周五")
    elif first == "S":
        second = str(input("输入："))
        if second == "u":
            print("是周日")
        else:
            print("是周六")


# timu31()


def timu31_1():
    zhou_dict = {
        "M": "Monday（星期一）",
        "T": {"u": "Tuesday（星期二）", "h": "Thursday（星期四）"},
        "W": "Wednesday（星期三）",
        "F": "Friday（星期五）",
        "S": {"a": "Saturday（星期六）", "u": "Sunday（星期日）"}
    }
    first = input("输入第一个字母：").upper()
    result1 = zhou_dict.get(first)
    print(result1)

    if result1:
        if isinstance(result1, dict):
            second = input("输入第二个字母：")
            result2 = result1.get(second)
            print(result2)
        else:
            print(result1)
    else:
        print("啥也不是")


# timu31_1()


"""
题目32：按相反的顺序输出列表的值。
"""


def timu32(newlist):
    for i in newlist[::-1]:
        print(i)


list_32 = ["1", "2", "3"]
# timu32(list_32)


def timu32_1(newlist):
    for i in range(len(newlist), 0, -1):
        print(i)


# timu32_1(list_32)

# 不修改原列表
def timu32_2(newlist):
    print(list(reversed(newlist)))


# timu32_2(list_32)
# print(list_32)


# 会修改原列表
def timu32_3(newlist):
    newlist.reverse()
    print(newlist)


list_32_1 = ["1", "2", "3"]
# timu32_3(list_32_1)
# print(list_32_1)


"""
题目33：按逗号分隔列表。
"""


def timu33(newlist):
    xinlist = ",".join(newlist)
    print(xinlist)


list_str = ["a", "b", "c"]
# timu33(list_str)


def timu33_1(newlist):
    # 这块儿的str 是必须的,处理混合类型列表的通用解决方案
    xinlist = ",".join(str(x) for x in newlist)
    print(xinlist)


list_int = [1, 2, 3, 4, 5]
# timu33_1(list_int)


def timu33_2(newlist):
    final_str = ""
    for i, x in enumerate(newlist):
        if i > 0:
            final_str += ","
        final_str += str(x)
    print(final_str)


list_mix = [1, 2, 3, 4, 5, "a", "b"]
# timu33_2(list_mix)


"""
题目34：练习函数调用。
"""


def hello_runoob():
    print('RUNOOB')


def hello_runoobs():
    for i in range(3):
        hello_runoob()


# if __name__ == '__main__':
#     hello_runoobs()


"""
题目35：文本颜色设置。
"""


class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


print(bcolors.WARNING + "警告的颜色字体?" + bcolors.ENDC)
print(bcolors.OKBLUE + "警告的颜色字体?" + bcolors.ENDC)
